<?php
/*
# ------------------------------------------------------------------------
# JA Job Board Package
# ------------------------------------------------------------------------
# Copyright (C) 2004-2010 JoomlArt.com. All Rights Reserved.
# @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
# Author: JoomlArt.com
# Websites: http://www.joomlart.com - http://www.joomlancers.com.
# ------------------------------------------------------------------------
*/

defined('_JEXEC') or die('Restricted access');

class JobBoardControllerJASendMail extends JobBoardController{

    /**
     * Constructor
     */
    function __construct( $default = array() )
    {
        parent::__construct( $default );
        $this->set('name', 'sendmail');
        $this->set('fullname', 'jasendmail');
        
        // Register Extra tasks

     }
    
    /**
    * Display current configuration of the component to administrator
    * 
    */
    function display(){
        JRequest::setVar('view', $this->get('fullname')); // Force using associated view
        $document = &JFactory::getDocument();
        $viewName = JRequest::getVar('view', $this->get('fullname'));
        $viewType = $document->getType();
        
        $model =& $this->getModel($this->get('fullname'));
        
        $view = &$this->getView($viewName, $viewType);
        $view->setModel($model, true);
        $view->setLayout(JBPREFIX."list");
        $view->display();
    }
    
    /**
    * Cancel current operation
    * 
    */
    function cancel(){
        $this->setRedirect("index.php?option=". JBCOMNAME ."&view=". $this->get('fullname'));
    }
    
    function sendfriend(){
        JRequest::setVar('view', $this->get('fullname')); // Force using associated view 
        $document = &JFactory::getDocument();
        $viewName = JRequest::getVar('view', $this->get('fullname'));
        $viewType = $document->getType();
        
        $model =& $this->getModel($this->get('fullname'));

        $view = &$this->getView($viewName, $viewType);
        $view->setModel($model, true);
        $view->setLayout(JBPREFIX."form");
        $view->edit();
    }
    
    function send(){
		$Itemid = JRequest::getVar('Itemid');
        $model = $this->getModel($this->get('fullname'));
        $model->sendjobs();
        $this->setMessage(JText::_('The job has been sent to your friend'));
        $this->setRedirect('index.php?option='. JBCOMNAME .'&view=jajobs&Itemid='. $Itemid);
    }
	
	
    
}
?>
